package com.jcp.baselibrary.dialog;


import com.jcp.baselibrary.R;

import static android.view.Gravity.CENTER;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

/**
 * =========================================================
 * @ProjectName:
 * @ClassName: BaseDialogBuilder
 * @Description: dialog配置
 * @Author: jincp
 * @CreateDate: 2019/3/14 20:09
 * =========================================================
 */
public abstract class BaseDialogBuilder<T extends BaseDialogBuilder, D extends BaseDialogFragment> {
    public int mWidth = WRAP_CONTENT;
    public int mHeight = WRAP_CONTENT;
    public int mGravity = CENTER;
    public int mOffsetX = 0;
    public int mOffsetY = 0;
    public float mBackGroundLevel = 0.4f;
    public int mAnimation = R.style.ScaleAnimation;
    public boolean mOutCancel = true;

    public T setSize(int mWidth, int mHeight) {
        this.mWidth = mWidth;
        this.mHeight = mHeight;
        return (T) this;
    }

    public T setGravity(int mGravity) {
        this.mGravity = mGravity;
        return (T) this;
    }

    public T setOffsetX(int mOffsetX) {
        this.mOffsetX = mOffsetX;
        return (T) this;
    }

    public T setOffsetY(int mOffsetY) {
        this.mOffsetY = mOffsetY;
        return (T) this;
    }

    public T setBackgroundLevel(float mBackGroundLevel) {
        this.mBackGroundLevel = mBackGroundLevel;
        return (T) this;
    }


    public T setAnimation(int mAnimation) {
        this.mAnimation = mAnimation;
        return (T) this;
    }

    public T setOutCancel(boolean mOutCancel) {
        this.mOutCancel = mOutCancel;
        return (T) this;
    }

    protected abstract D build();

    protected void clear() {
        this.mWidth = WRAP_CONTENT;
        this.mHeight = WRAP_CONTENT;
        this.mGravity = CENTER;
        this.mOffsetX = 0;
        this.mOffsetY = 0;
        this.mAnimation = R.style.ScaleAnimation;
        this.mOutCancel = true;
    }
}
